<template>
	<view class="container">
		<view class="loading-wrapper">
			<image class="loading-spinner" src="/static/h.png"></image>
			<view class="loading-text">Starting。。。</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			this.initializeLanguage()
			//检查登录状态
			const token = uni.getStorageSync('token');
			setTimeout(() => {
				if (token) {
					// 已登录，跳转到首页
					uni.switchTab({
						url: '/pages/tabbar/tabbar_business'
					});
				} else {
					// 未登录，跳转到登录页
					uni.reLaunch({
						url: '/pages/login/login'
					});
				}
			}, 500);
		},
		methods:{
			initializeLanguage() {
				// 优先从本地存储获取语言设置
				const storedLanguage = uni.getStorageSync('currentLanguage');
				// 如果没有存储的语言，则使用系统语言
				const systemLanguage = uni.getLocale();
				// 设置当前语言，默认使用英语
				this.currentLanguage = storedLanguage || systemLanguage || 'en';
				console.log('初始化语言:', this.currentLanguage);
				// 应用i18n语言设置
				if (this.$i18n) {
					this.$i18n.locale = this.currentLanguage;
				}
			},
		},
	}
</script>

<style>
	.container {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background-color: #ffffff;
	}
	
	.loading-wrapper {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	
	.loading-spinner {
		width: 300rpx;
		height: 300rpx;
		margin-bottom: 30rpx;
	}
	
	.loading-text {
		color: #666666;
		font-size: 32rpx;
	}
</style>